#include "AccCon.h"
#include "ComDef.h"
#include "ZoneSvr.h"
#include "player/PlayerMgr.h"

using namespace su;
using namespace std;
using namespace proto;


bool AccCon::Init()
{
	AdFacadeInitData d;
	d.mainCmd = (uint16)SvrType::Zone;
	d.svrId = ZoneSvr::Ins().Cfg().svrId;
	d.vecAccAddr = ZoneSvr::Ins().Cfg().vecAcc;
	for (auto& v : d.vecAccAddr)
	{
		LDEBUG("con to access ", v.ip, v.port);
	}
	return ADFacadeMgr::Ins().Init(*this, d);
}

void AccCon::OnRevClientMsg(const proto::Session& session, uint32 cmd, const std::string& msg)
{
	ProtoDispatch::Ins().Dispatch(session, cmd, msg);
}

void AccCon::OnClientDisCon(const proto::Session& sn)
{
	Player *player = sn.GetWeakEx<Player>();
	L_COND_V(player);
	player->m_Net.OnClientDisCon();
}